package org.ejc.struts.registration;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorForm;
import org.ejc.struts.address.AddressForm;

/**
 * Form for registrant.
 * 
 * @author <a href="http://boss.bekk.no/boss/middlegen/"/>Middlegen</a>
 * 
 * @struts.form name="registrationForm"
 */
public class RegistrationForm extends ValidatorForm implements Serializable {

	
	private static final long serialVersionUID = 1L;

	
	private java.lang.Integer _registrantId = null;

	private java.lang.String _firstName = null;

	private java.lang.String _lastName = null;

	private java.lang.String _email = null;

	private java.lang.String _notes = null;

	private java.lang.Integer _addressId = null;
	
	
	private String ageBracket=null;
	
	private Integer registrantTypeId;
	private Integer accomodationTypeId;
	private boolean guestArrived;
	private String preRegInput;
	
	

	// the address form. Use delegator methods for this which makes it easy on
	// jsp level
	private AddressForm addressForm = null;

	private boolean preRegistration;

	//OK BELOW ARE THE DETAILS FOR THE CONVENTION_REGISTRANT TABLE.
	//BUT ITS EASIER IF WE KEEP THEM IN THIS FORM AS THEY WILL BE
	//SUBMITTED IN THIS ACTION (ALL IN ONE GO)
	
	//is this a preReg.
	private boolean preReg;
	
	//length of stay
	private Integer lengthOfStay;
	private String contactNumber;
	
	/**
     * Reset all properties to their default values.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     */
    public void reset(ActionMapping mapping, HttpServletRequest request) {
       _firstName = null;
       _lastName = null;
       addressForm = new AddressForm();
       _email=null;
       _notes=null;
       ageBracket="N/A";
       
    }
	
	
	/**
	 * Standard constructor.
	 */
	public RegistrationForm() {
		addressForm = new AddressForm();
		ageBracket="N/A";
	}

	/**
	 * Returns the registrantId
	 * 
	 * @return the registrantId
	 */
	public java.lang.Integer getRegistrantId() {
		return _registrantId;
	}

	/**
	 * Sets the registrantId
	 * 
	 * @param registrantId
	 *            the new registrantId value
	 */
	public void setRegistrantId(java.lang.Integer registrantId) {
		_registrantId = registrantId;
	}

	/**
	 * Returns the firstName
	 * 
	 * @return the firstName
	 */
	public java.lang.String getFirstName() {
		return _firstName;
	}

	/**
	 * Sets the firstName
	 * 
	 * @param firstName
	 *            the new firstName value
	 * 
	 * @struts.validator type="required"
	 * @struts.validator-args arg0resource="page.registration.firstName"
	 * 
	 */
	public void setFirstName(java.lang.String firstName) {
		_firstName = firstName;
	}

	/**
	 * Returns the lastName
	 * 
	 * @return the lastName
	 */
	public java.lang.String getLastName() {
		return _lastName;
	}

	/**
	 * Sets the lastName
	 * 
	 * @param lastName
	 *            the new lastName value
	 * 
	 * @struts.validator type="required"
	 * @struts.validator-args arg0resource="page.registration.lastName"
	 * 
	 */
	public void setLastName(java.lang.String lastName) {
		_lastName = lastName;
	}

	/**
	 * Returns the email
	 * 
	 * @return the email
	 */
	public java.lang.String getEmail() {
		return _email;
	}

	/**
	 * Sets the email
	 * 
	 * @param email
	 *            the new email value
	 * 
	 * @struts.validator type="email"
	 * @struts.validator-args arg0resource="page.registration.email"
	 * 
	 */
	public void setEmail(java.lang.String email) {
		_email = email;
	}

	/**
	 * Returns the notes
	 * 
	 * @return the notes
	 */
	public java.lang.String getNotes() {
		return _notes;
	}

	/**
	 * Sets the notes
	 * 
	 * @param notes
	 *            the new notes value
	 * 
	 */
	public void setNotes(java.lang.String notes) {
		_notes = notes;
	}

	/**
	 * @return Returns the preRegistration.
	 */
	public boolean getPreRegistration() {
		return preRegistration;
	}


	/**
	 * @param preRegistration The preRegistration to set.
	 */
	public void setPreRegistration(boolean preRegistration) {
		this.preRegistration = preRegistration;
	}

	

	/**
	 * @return Returns the registrantTypeId.
	 */
	public Integer getRegistrantTypeId() {
		return registrantTypeId;
	}


	/**
	 * @param registrantTypeId The registrantTypeId to set.
	 * @struts.validator type="required,intRange"
	 * @struts.validator-args arg0resource="page.registration.type"
	 * 
	 * @struts.validator-var name="min" value="1"
	 * @struts.validator-var name="max" value="2000"
	 * 
	 */
	public void setRegistrantTypeId(Integer registrantTypeId) {
		this.registrantTypeId = registrantTypeId;
	}

	

	/**
	 * @return Returns the accomodationTypeId.
	 */
	public Integer getAccomodationTypeId() {
		return accomodationTypeId;
	}

	/**
	 * Sets the accomodationTypeId
	 * 
	 ** @param notes
	 *            the new notes value
	 * 
	 * 
	 * 
	 */
	public void setAccomodationTypeId(Integer accomodationTypeId) {
		this.accomodationTypeId = accomodationTypeId;
	}


	/**
	 * @return Returns the contactNumber.
	 */
	public String getContactNumber() {
		return contactNumber;
	}


	/**
	 * @param contactNumber The contactNumber to set.
	 */
	public void setContactNumber(String contactNumber) {
		this.contactNumber = contactNumber;
	}


	/**
	 * Returns the addressId
	 * 
	 * @return the addressId
	 */
	public java.lang.Integer getAddressId() {
		return _addressId;
	}

	/**
	 * Sets the addressId
	 * 
	 * @param addressId
	 *            the new addressId value
	 */
	public void setAddressId(java.lang.Integer addressId) {
		_addressId = addressId;
	}

//	/**
//	 * Validate the properties that have been set from this HTTP request, and
//	 * return an <code>ActionErrors</code> object that encapsulates any
//	 * validation errors that have been found. If no errors are found, return
//	 * <code>null</code> or an <code>ActionErrors</code> object with no
//	 * recorded error messages.
//	 * 
//	 * @param mapping
//	 *            The mapping used to select this instance
//	 * @param request
//	 *            The servlet request we are processing
//	 */
//	public ActionErrors validate(ActionMapping mapping,
//			HttpServletRequest request) {
//		ActionErrors errors = new ActionErrors();
//		// test for nullity
//		// if(getRegistrantId() == null) {
//		// errors.add("registrantId", new
//		// ActionError("error.registrantId.required"));
//		// }
//		// TODO test format/data
//		return errors;
//	}

	public AddressForm getAddressForm() {
		return addressForm;
	}

	public void setAddressForm(AddressForm addressForm) {
		this.addressForm = addressForm;
	}

	public String getAddressLine1() {
		return addressForm.getAddressLine1();
	}

	public String getAddressLine2() {
		return addressForm.getAddressLine2();
	}

	public String getCityTown() {
		return addressForm.getCityTown();
	}

	public Integer getCountryCodeCountryId() {
		return addressForm.getCountryCodeCountryId();
	}

	public void setAddressId(Object addressId) {
		addressForm.setAddressId(addressId);
	}

	/**
	 * Sets the addressLine1
	 * 
	 * @param addressLine1
	 *            the new addressLine1 value
	 * 
	 */
	public void setAddressLine1(String addressLine1) {
		addressForm.setAddressLine1(addressLine1);
	}

	/**
	 * Sets the addressLine2
	 * 
	 * @param addressLine2
	 *            the new addressLine2 value
	 * 
	 */
	public void setAddressLine2(String addressLine2) {
		addressForm.setAddressLine2(addressLine2);
	}
	
	/**
	 * Sets the cityTown
	 * 
	 * @param cityTown
	 *            the new cityTown value
	 * 
	 */
	public void setCityTown(String cityTown) {
		addressForm.setCityTown(cityTown);
	}

	
	/**
	 * Sets the countryCodeCountryId
	 * 
	 * @param countryCodeCountryId
	 *            the new countryCodeCountryId value
	 * 
	 * @struts.validator type="required,intRange"
	 * @struts.validator-args arg0resource="page.registration.country"
	 * 
	 * @struts.validator-var name="min" value="1"
	 * @struts.validator-var name="max" value="2000"
	 * 
	 */
	public void setCountryCodeCountryId(Integer countryCodeCountryId) {
		addressForm.setCountryCodeCountryId(countryCodeCountryId);
	}


	public Integer getLengthOfStay() {
		return lengthOfStay;
	}


	public void setLengthOfStay(Integer lengthOfStay) {
		this.lengthOfStay = lengthOfStay;
	}


	public boolean isPreReg() {
		return preReg;
	}


	public void setPreReg(boolean preReg) {
		this.preReg = preReg;
	}


	/**
	 * @return Returns the guestArrived.
	 */
	public boolean getGuestArrived() {
		return guestArrived;
	}


	/**
	 * @param guestArrived The guestArrived to set.
	 */
	public void setGuestArrived(boolean guestArrived) {
		this.guestArrived = guestArrived;
	}


	public String getAgeBracket() {
		return ageBracket;
	}


	public void setAgeBracket(String ageBracket) {
		this.ageBracket = ageBracket;
	}


	/**
	 * @return Returns the preRegInput.
	 */
	public String getPreRegInput() {
		return preRegInput;
	}


	/**
	 * @param preRegInput The preRegInput to set.
	 */
	public void setPreRegInput(String preRegInput) {
		this.preRegInput = preRegInput;
	}

	
}
